/*  
Creates table 3 in paper. Covariance between the predicted and residual components of building beauty and image uploads: OLS and Negative Binomial estimates


Requires the clean dataset:
${project}/clean_data/survey_level_data.dta

Arianna Salazar Miranda
*/

clear all
global project "/Users/arianna/Dropbox (MIT)/emporis_project/paper/submission_PLOS/data_repository"

**************************************************************************************************
*open survey database
**************************************************************************************************

use "${project}/Data/survey_level_data.dta", clear
merge m:1 buildingnumberebn using "${project}/Data/building_characteristics.dta"

**************************************************************************************************
*cleaning
**************************************************************************************************

drop if officialname=="Mark Twain Building"
drop if officialname=="Empire State Building"
drop if officialname=="Byrd's Lofts"


**************************************************************************************************
*generate additional variables for table 3
**************************************************************************************************

*tag duplicate buildings
bysort buildingnumberebn: gen tag_unique=(_n==_N)

egen st_sid=group(session_id)
bysort buildingnumberebn: egen score_mean=mean(score)
bysort buildingnumberebn: egen count_building=count(score)


**************************************************************************************************
*TABLE 3
**************************************************************************************************

reg score_mean building_height building_year building_height_2 building_year_2 i.archsty_enc if tag==1 [w=count_building],  r
predict observable_beauty 
predict unobservable_beauty, resid

******************************
* 1) OLS*
******************************
reg r50_count_picData_2014 observable_beauty if tag==1,  r

******************************
* 2) OLS*
******************************
reg r50_count_picData_2014 observable_beauty unobservable_beauty  if tag==1,  r

******************************
* 3) NEGATIVE BINOMIAL*
******************************
nbreg r50_count_picData_2014 observable_beauty if tag==1,  r

******************************
* 4) NEGATIVE BINOMIAL*
******************************
nbreg r50_count_picData_2014 observable_beauty unobservable_beauty  if tag==1,  r

